package org.jcut.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.jcut.config.UserStatisticsListener;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/UserListener")
public class UserListenerController {
	@RequestMapping("/logUser")    

	public String logUser(HttpServletRequest request, HttpServletResponse response){        

	HttpSession session=request.getSession();
	session.setAttribute("name", "content");
	session.setMaxInactiveInterval(3);
	return request.getParameter("name")+"登录成功！当前在线用户人数是："+ UserStatisticsListener.count;    

	}    

	@RequestMapping("/logOut")    

	public String logOut(HttpServletRequest request, HttpServletResponse response){        

	request.getSession().invalidate();        

	return request.getParameter("name")+"登出成功！当前在线用户人数是："+UserStatisticsListener.count;    

	}
}
